package com.xiaoshuidi.cloud.module.member.api.user;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.module.member.api.user.dto.MemberUserAuthInfoDTO;
import com.xiaoshuidi.cloud.module.member.api.user.dto.MemberUserPageDTO;
import com.xiaoshuidi.cloud.module.member.api.user.dto.MemberUserReqDTO;
import com.xiaoshuidi.cloud.module.member.api.user.dto.MemberUserRespDTO;
import com.xiaoshuidi.cloud.module.member.api.user.dto.ThirdPayUserReqDTO;
import com.xiaoshuidi.cloud.module.member.service.user.MemberUserService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

import static com.xiaoshuidi.cloud.module.system.enums.ApiConstants.VERSION;

/**
 * 会员用户的 API 实现类
 *
 * @author 芋道源码
 */
@Tag(name = "RPC 服务 - 会员")
@Slf4j
@RestController
@DubboService(version = VERSION)
@Validated
@RequiredArgsConstructor
public class MemberUserApiImpl implements MemberUserApi {

    @Resource
    private MemberUserService userService;

//    @Override
//    public MemberUserRespDTO getUser(Long id) {
//        MemberUser user = userService.getUser(id);
//        return UserConvert.INSTANCE.convert2(user);
//    }
//
//    @Override
//    public List<MemberUserRespDTO> getUsers(Collection<Long> ids) {
//        return UserConvert.INSTANCE.convertList2(userService.getUserList(ids));
//    }
//
//    @Override
//    public List<MemberUserRespDTO> getUserListByNickname(String nickname) {
//        return UserConvert.INSTANCE.convertList2(userService.getUserListByNickname(nickname));
//    }
//
//    @Override
//    public MemberUserRespDTO getUserByMobile(String mobile) {
//        return UserConvert.INSTANCE.convert2(userService.getUserByMobile(mobile));
//    }

    @Override
    public CommonResult<MemberUserRespDTO> getUserInfo(@RequestBody MemberUserReqDTO req) {
        return CommonResult.success(userService.getUserInfo(req));
    }

    @Override
    public CommonResult<MemberUserAuthInfoDTO> getUserAuthInfo(String moible) {
        return CommonResult.success(userService.getUserAuthInfo(moible));
    }

    @Override
    public CommonResult<PageResult<MemberUserRespDTO>> getUserPage(MemberUserPageDTO page) {
        return CommonResult.success(userService.getUserPage(page));
    }

    @Override
    public CommonResult<List<MemberUserRespDTO>> getUsersByIds(List<Long> ids) {
        return CommonResult.success(userService.getUsersByIds(ids));
    }

    @Override
    public CommonResult<MemberUserRespDTO> getUserById(Long id) {
        return CommonResult.success(userService.getUserById(id));
    }

    @Override
    public CommonResult<Boolean> registerThirdMember(ThirdPayUserReqDTO thirdPayUserReqDTO) {
        return CommonResult.success(userService.registerThirdMember(thirdPayUserReqDTO));
    }

    @Override
    public CommonResult<Boolean> bindPayFlag(Long id) {
        return  CommonResult.success(userService.bindPayFlag(id));
    }

    @Override
    public CommonResult<MemberUserRespDTO> getUserByCardNo(String cardNo) {
        return CommonResult.success(userService.getUserByCardNo(cardNo));
    }

}
